package com.jhhe.mr.mysort;

import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

public class MySortReducer extends Reducer<MySortBean, NullWritable, MySortBean, NullWritable> {

    @Override
    protected void reduce(MySortBean key, Iterable<NullWritable> values, Context context) throws IOException, InterruptedException {
        for (NullWritable value : values) { // 遍历value同时，key也会随着遍历
            key.setId(MySortDriver.countN++);
            context.write(key, value);
        }
    }
}
